package hichecker.ui.general_views.container_panel.navigation;

import hichecker.ui.components.icon_factory.IconFactory;
import hichecker.university.UniversityPart;

import java.awt.Component;

import javax.swing.DefaultListCellRenderer;
import javax.swing.JLabel;
import javax.swing.JList;

public class NavigationCellRenderer extends DefaultListCellRenderer {
	@Override
	public Component getListCellRendererComponent(JList list, Object value,
			int index, boolean isSelected, boolean cellHasFocus) {
		JLabel label = (JLabel) super.getListCellRendererComponent(list,
				value, index, isSelected, cellHasFocus);
		
        if (value instanceof UniversityPart) {
        	UniversityPart item = (UniversityPart) value;
        	label.setText(item.getName());
        	label.setIcon(IconFactory.getIcon(item.getIcon()));
        	label.setToolTipText(item.getName());
        } else {
        	label.setText(value.toString());
        }
        
		return label;
	}
}
